﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace QYmall.Core.Model.ViewModels
{
    /// <summary>
    /// 商户文章(显示)
    /// </summary>
    public class MerchantArticleDto : MerchantArticleEditDto
    {
        /// <summary>
        /// 自增ID
        /// </summary>
        [Display(Name = "自增ID")]
        public long Id { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [Display(Name = "创建人")]
        public string? AddBy { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Display(Name = "创建时间")]
        public DateTime AddTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新人
        /// </summary>
        [Display(Name = "更新人")]
        [StringLength(128)]
        public string? UpdateBy { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        [Display(Name = "更新时间")]
        public DateTime? UpdateTime { get; set; }

        /// <summary>
        /// 店铺名称
        /// </summary>
        [Display(Name = "店铺名称")]
        public string? MerchantTitle { get; set; }

        /// <summary>
        /// 店铺头像
        /// </summary>
        [Display(Name = "店铺头像")]
        public string? MerchantAvatar { get; set; }

        /// <summary>
        /// 分类名称
        /// </summary>
        [Display(Name = "分类名称")]
        public string? CategoryTitle { get; set; }
    }

    /// <summary>
    /// 商户文章(编辑)
    /// </summary>
    public class MerchantArticleEditDto
    {
        /// <summary>
        /// 所属商户ID
        /// </summary>
        [Display(Name = "所属商户")]
        public int? MerchantId { get; set; }

        /// <summary>
        /// 所属分类ID
        /// </summary>
        [Display(Name = "所属分类")]
        [Required(ErrorMessage = "{0}不可为空")]
        public int CategoryId { get; set; }

        /// <summary>
        /// 文章标题
        /// </summary>
        [Display(Name = "标题")]
        [Required(ErrorMessage = "{0}不可为空")]
        [MaxLength(512, ErrorMessage = "{0}不可超出{1}字符")]
        public string Title { get; set; } = string.Empty;

        /// <summary>
        /// 文章来源
        /// </summary>
        [Display(Name = "来源")]
        [MaxLength(128, ErrorMessage = "{0}不可超出{1}字符")]
        public string Source { get; set; } = string.Empty;

        /// <summary>
        /// 文章作者
        /// </summary>
        [Display(Name = "作者")]
        [MaxLength(128, ErrorMessage = "{0}不可超出{1}字符")]
        public string Author { get; set; } = string.Empty;

        /// <summary>
        /// 图片地址
        /// </summary>
        [Display(Name = "图片地址")]
        [MaxLength(512, ErrorMessage = "{0}不可超出{1}字符")]
        public string ImgUrl { get; set; } = string.Empty;

        /// <summary>
        /// 内容摘要
        /// </summary>
        [Display(Name = "内容摘要")]
        [MaxLength(255, ErrorMessage = "{0}不可超出{1}字符")]
        public string? Zhaiyao { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        [Display(Name = "内容")]
        public string? Content { get; set; }

        /// <summary>
        /// 排序数字
        /// </summary>
        [Display(Name = "排序数字")]
        public int SortId { get; set; } = 99;

        /// <summary>
        /// 浏览总数
        /// </summary>
        [Display(Name = "浏览总数")]
        public int Click { get; set; } = 0;

        /// <summary>
        /// 状态0正常1待审2已删
        /// </summary>
        [Display(Name = "状态")]
        public byte Status { get; set; } = 0;
    }

    /// <summary>
    /// 商户文章(前端)
    /// </summary>
    public class MerchantArticleClientDto : MerchantArticleEditDto
    {
        /// <summary>
        /// 自增ID
        /// </summary>
        [Display(Name = "自增ID")]
        public long Id { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Display(Name = "创建时间")]
        public DateTime AddTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 店铺名称
        /// </summary>
        [Display(Name = "店铺名称")]
        public string? MerchantTitle { get; set; }

        /// <summary>
        /// 店铺头像
        /// </summary>
        [Display(Name = "店铺头像")]
        public string? MerchantAvatar { get; set; }

        /// <summary>
        /// 分类名称
        /// </summary>
        [Display(Name = "分类名称")]
        public string? CategoryTitle { get; set; }
    }
}
